package comic

import (
	"common"
	"models/dal/query"
	"time"
)

// IncrHotSearchNum 增加热么搜索词的数量
func IncrHotSearchNum(content string) {
	ctx, cancel := common.WithTimeoutContext(time.Second * 2)
	defer cancel()
	//增加这个title的搜索数量
	hotSearchModel := query.Q.FaHotSearch.WithContext(ctx)
	//查询是否存在这个
	hotSearchRaw, err := hotSearchModel.Where(query.Q.FaHotSearch.Content.Eq(content)).FirstOrCreate()
	if err != nil {
		return
	}
	hotSearchRaw.Num++
	hotSearchModel.Save(hotSearchRaw)
	return
}
